MySQL User Password Expired: how to (permanently) fix it

您所在的位置:网站首页 uiuc password expire MySQL User Password Expired: how to (permanently) fix it

MySQL User Password Expired: how to (permanently) fix it

2024-07-17 17:34:57| 来源: 网络整理| 查看: 265

Table of Contents

How to reset an expired root passwordHow to disable the automatic password expiration policy

If you stumbled upon this post it probably means that your favourite MySQL management client (SQLyog, MySQL Workbench or any other) and/or your MySQL-based website or service is suddently unable to connect to your database server, leaving you with the following error message:

Your password has expired. To log in you must change it using a client that supports expired passwords.

This is a rather normal behaviour from MySQL 5.7.4 and above, where the automatic password expiration policy is enabled by default with a 360 days threshold -  meaning that all passwords will expire once a year. To read more about this, we strongly suggest to read the official MySQL 5.7 documentation by clicking here.

In a standard scenario, fixing such issue can be rather easy: you just have to login with an administrative user - such as the local root user - and change the expired password accordingly: needless to say, if the credentials are stored within a script (or website) configuration file, you will also need to change the password there as well. However, there are at least two scenarios that require further actions to take:

If the root user password is also expired. If we want to prevent such issue from happening again.

The purpose of this post is to give a viable answer for both of them.

How to reset an expired root password

Among a wide number of available workarounds, I strongly suggest using the following (it works on Windows and Linux systems):

Stop the MySQL service/process. Locate and open the MySQL configuration file used by your running MySQL instance (usually   C:\ProgramData\MySQL\MySQL Server 5.7\my.ini  in Windows, /etc/mysql/my.cnf  or /etc/mysql/my.cnf  under Linux). Add the following lines just below the [mysqld]  section: INI 123 # Uncomment the following line to disable password check. # WARNING: this will allow any user to login, even with a wrong or expired password!!!skip-grant-tables Restart the MySQL service/process. Login to the server using your favourite MySQL GUI client with the root user - or any other administrative user - using any password (or even no passwords at all). Execute the following query: UPDATE mysql.user SET authentication_string = PASSWORD('YourPassword'), password_expired = 'N' WHERE User = 'YourUser' AND Host = 'YourHost'; FLUSH PRIVILEGES;  Don't forget to change the YourPassword  YourUser and YourHost placeholders with your choosen password, user and user's host (which is usually *  or localhost ). Note that you can even change the root@localhost account's password there, in which case you need to specify User = 'root' AND Host = 'localhost' . Open the MySQL configuration file again and comment-out the skip-grant-tables  command added moments ago. Stop and restart the MySQL service/process.

That's it!

If you don't want to alter the configuration file, you can just stop the mysqld  server/process and then launch it again adding the   --skip-grant-tables  option. If you have no MySQL clients available, you can also do the latest 4 steps from the command prompt by using the mysql command, which is available in the /bin/  folder. Just type mysql -u root  to access the mysql prompt: no password is necessary because the server was started with the   --skip-grant-tables  option.

How to disable the automatic password expiration policy

The following query can be used to disable the automatic password expiration for a specific user:

MySQL 1 ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;

To establish a global policy such that passwords never expire, you can add (or change) this option to your MySQL configuration file:

INI 12 [mysqld]default_password_lifetime=0

IMPORTANT: you'll still need to manually set PASSWORD EXPIRE NEVER for every user created before the global policy change.

That's all for now: happy MySQL!

 

 

 

Print Friendly, PDF & EmailPrint Friendly & PDF Download


【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


    图片新闻

    实验室药品柜的特性有哪些
    实验室药品柜是实验室家具的重要组成部分之一,主要
    小学科学实验中有哪些教学
    计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
    实验室各种仪器原理动图讲
    1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
    高中化学常见仪器及实验装
    1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
    微生物操作主要设备和器具
    今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
    浅谈通风柜使用基本常识
     众所周知,通风柜功能中最主要的就是排气功能。在

    专题文章

      CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭